from django.views.decorators.csrf import csrf_exempt
from django.shortcuts import render
from django.http import HttpResponse
import json
from django.conf import settings
# Create your views here.
def index(request):
    return HttpResponse("Hello, world. You're at the polls index.")

@csrf_exempt
def split(request):
    pword = ''
    if request.POST:
        pword = request.POST['word']
    elif request.GET:
        pword = request.GET['word']
    seg_list = settings.JIEBA.lcut(pword, cut_all=False)
    print('seg_list--------------->',seg_list)
    resp = {'success':True,'word_arr': seg_list}
    return HttpResponse(json.dumps(resp),content_type='application/json')